package org.qiancizhan.Controller;

import org.qiancizhan.Mapper.WordMapper;
import org.qiancizhan.Model.DTO.BookWordsDTO;
import org.qiancizhan.Model.POJO.WordPOJO;
import org.qiancizhan.Model.VO.WordsVO;

import java.util.List;

public class WordController {
    private final WordMapper wordMapper = new WordMapper();

    //获取该书的单词
    public WordsVO getWords(BookWordsDTO bookWordsDTO) {
        return wordMapper.getWords(bookWordsDTO);
    }

    public List<WordPOJO> getNumWords(int num) {
        return wordMapper.getNumWords(num);
    }


    public List<WordPOJO> getWordInfo(String input) {
        if (input == null || input.isEmpty()) return null;
        boolean isEnglish = input.matches("[a-zA-Z]+");
        input = input.toLowerCase();
        return wordMapper.getWordInfo(input,isEnglish);
    }
}
